//
//  DiscoverSessionView.m
//  MindBox
//
//  Created by MS on 16-1-6.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//
#import "UIView+Frame.h"
#import "DiscoverSessionView.h"
#import "Discover_WelfareCell.h"
#import "DisCover_Welfare_SpeCell.h"
#import "Discover_MindCell.h"
#define Margin 10
#define WelHeight 160
#define MindHeiht 310
@interface DiscoverSessionView ()<UITableViewDelegate,UITableViewDataSource,Discover_MindCellDelegate>

@property (nonatomic,strong)  NSMutableArray * totalLastTime;
@property (nonatomic,strong) NSArray * mindArray;
@property (nonatomic,strong) NSTimer * timer;
@end

@implementation DiscoverSessionView


-(void)setActivityArray:(NSArray *)activityArray
{
    _activityArray = activityArray;
    self.mindArray = activityArray;
    [self.tableView reloadData];
}


-(NSArray *)mindArray
{
    if (_mindArray==nil) {
        _mindArray = [[NSArray alloc] init];

    }
    return _mindArray;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UITableView * tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStylePlain];
        tableView.backgroundColor = [UIColor colorWithRed:0.97f green:0.97f blue:0.97f alpha:1.00f];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        tableView.contentInset = UIEdgeInsetsMake(0, 0, 64, 0);
        [self addSubview:tableView];
        self.tableView = tableView;
        tableView.dataSource = self;
        tableView.delegate = self;
    }
    return self;
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.mindArray.count;;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        Activity * activity = self.mindArray[indexPath.row];
        activity.index = indexPath.row;
        Discover_MindCell * mindcell = [Discover_MindCell cellWithTableView:tableView];
        mindcell.delegate = self;
        mindcell.activity = activity;
    
      return mindcell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return MindHeiht;
}


-(void)discover_mindCellDidClick:(Discover_MindCell *)mindCell activity:(Activity *)activity goods:(Goods *)goods index:(NSInteger)index
{
    
    if ([self.delegate respondsToSelector:@selector(discoverMindSessionViewDidClick:activity:goods:index:)]) {
        [self.delegate discoverMindSessionViewDidClick:self activity:activity goods:goods index:index];
    }
    
}



@end
